import {  getSession, sidebar_flag, user_info, role_info, tag_list } from '../utils/config'

const getters = {
  sidebar: state => {
    let f = state.app.sidebar !== null ? state.app.sidebar : getSession(sidebar_flag)
    return f
  },
  tagList: state => {
    let tagList = state.app.tagList.length === 0 ? getSession(tag_list) : state.app.tagList
    return tagList
  },
  user: state => {
    let u = state.user.user.name ? state.user.user : getSession(user_info)
    return u
  },
  roles: state => {
    let r = state.user.roles.length > 0 ? state.user.roles : Object.keys(getSession(role_info)).length === 0 ? [] : getSession(role_info)
    return r
  }
}
export default getters
